package com.cloudkinto.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

/**
 * <p>
 * 产品表
 * </p>
 *
 * @author long
 * @since 2024-10-29
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("t_product")
public class ProductDo extends Model<ProductDo> {

    private static final long serialVersionUID = 1L;

    /**
     * 产品主键id
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 客户代码
     */
    @TableField(value = "company_id", fill = FieldFill.INSERT)
    private Long companyId;

    /**
     * 租户id
     */
    @TableField(value = "tenant_id", fill = FieldFill.INSERT)
    private Long tenantId;

    /**
     * 分类id
     */
    @TableField("category_id")
    private Long categoryId;

    /**
     * SKU
     */
    @TableField("sku")
    private String sku;

    @TableField("spu")
    private String spu;

    @TableField("jan_code")
    private String janCode;

    /**
     * 产品名
     */
    @TableField("product_name")
    private String productName;

    /**
     * 产品别名
     */
    @TableField("product_alias_name")
    private String productAliasName;

    /**
     * 产品描述
     */
    @TableField("product_description")
    private String productDescription;

    /**
     * 产品图片
     */
    @TableField("pic_id")
    private Long picId;

    /**
     * 是否免审
     */
    @TableField("exempt_check")
    private Boolean exemptCheck;

    /**
     * 审批状态 0草稿 1审核中 2已审核 3已驳回 4废弃
     */
    @TableField("approve_status")
    private Integer approveStatus;

    /**
     * 废弃前的状态
     */
    @TableField("old_approve_status")
    private Integer oldApproveStatus;

    /**
     * 审核驳回理由
     */
    @TableField("approve_reject_reason")
    private String approveRejectReason;

    /**
     * 审核时间
     */
    @TableField("approve_time")
    private Date approveTime;

    /**
     * 是否需要包材
     */
    @TableField("need_pack")
    private Boolean needPack;

    /**
     * 包材详情 [{packCode,packName,whId,whCode,whName}]  ProductPackInfoDto.class
     */
    @TableField("pack_info")
    private String packInfo;

    /**
     * 原产地简码
     */
    @TableField("country_of_origin")
    private String countryOfOrigin;

    /**
     * 申报价格 货币代码
     */
    @TableField("currency_code")
    private String currencyCode;

    /**
     * 海关编码
     */
    @TableField("customhouse_code")
    private String customhouseCode;

    /**
     * 所属危险品
     */
    @TableField("dangerous_cargo")
    private Integer dangerousCargo;

    /**
     * 申报中文名
     */
    @TableField("declare_name_cn")
    private String declareNameCn;

    /**
     * 申报英文名
     */
    @TableField("declare_name_en")
    private String declareNameEn;

    /**
     * 申报价格
     */
    @TableField("declare_price")
    private BigDecimal declarePrice;

    /**
     * 产品条码(EAN/UPC)
     */
    @TableField("main_barcode")
    private String mainBarcode;

    /**
     * FNSKU
     */
    @TableField("fn_sku")
    private String fnSku;

    /**
     * 高 公制
     */
    @TableField("height")
    private BigDecimal height;

    /**
     * 高 英制
     */
    @TableField("height_bs")
    private BigDecimal heightBs;

    /**
     * 长 公制
     */
    @TableField("length")
    private BigDecimal length;

    /**
     * 长 英制
     */
    @TableField("length_bs")
    private BigDecimal lengthBs;

    /**
     * 宽 公制
     */
    @TableField("width")
    private BigDecimal width;

    /**
     * 宽 英制
     */
    @TableField("width_bs")
    private BigDecimal widthBs;

    /**
     * 重量 公制
     */
    @TableField("weight")
    private BigDecimal weight;

    /**
     * 重量 英制
     */
    @TableField("weight_bs")
    private BigDecimal weightBs;

    /**
     * 其他条码多个逗号隔开
     */
    @TableField("other_barcode")
    private String otherBarcode;

    /**
     * 高 公制
     */
    @TableField("wms_height")
    private BigDecimal wmsHeight;

    /**
     * 高 英制
     */
    @TableField("wms_height_bs")
    private BigDecimal wmsHeightBs;

    /**
     * 长 公制
     */
    @TableField("wms_length")
    private BigDecimal wmsLength;

    /**
     * 长 英制
     */
    @TableField("wms_length_bs")
    private BigDecimal wmsLengthBs;

    /**
     * 宽 公制
     */
    @TableField("wms_width")
    private BigDecimal wmsWidth;

    /**
     * 宽 英制
     */
    @TableField("wms_width_bs")
    private BigDecimal wmsWidthBs;

    /**
     * 重量 公制
     */
    @TableField("wms_weight")
    private BigDecimal wmsWeight;

    /**
     * 重量 英制
     */
    @TableField("wms_weight_bs")
    private BigDecimal wmsWeightBs;

    /**
     * wms测量时间
     */
    @TableField("wms_measure_time")
    private Date wmsMeasureTime;

    /**
     * 废弃时间
     */
    @TableField("discard_time")
    private Date discardTime;

    /**
     * 创建人
     */
    @TableField(value = "create_by_name", fill = FieldFill.INSERT)
    private String createByName;

    /**
     * 创建人
     */
    @TableField(value = "create_by", fill = FieldFill.INSERT)
    private Long createBy;

    /**
     * 创建时间
     */
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    private Date createTime;

    /**
     * 修改人
     */
    @TableField(value = "update_by", fill = FieldFill.INSERT_UPDATE)
    private Long updateBy;

    /**
     * 修改时间
     */
    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    private Date updateTime;

    /**
     * 备注
     */
    @TableField("remark")
    private String remark;

    @TableField("delete_flag")
    @TableLogic
    private Integer deleteFlag;

    public BigDecimal getDeclarePrice() {
        if (declarePrice == null) {
            return BigDecimal.ZERO;
        }
        return declarePrice;
    }

    @TableField("three_days_weight")
    private Double threeDaysWeight;

    @TableField("seven_days_weight")
    private Double sevenDaysWeight;

    @TableField("thirty_days_weight")
    private Double thirtyDaysWeight;

    @TableField("attribute1")
    private String attribute1;

    @TableField("attribute2")
    private String attribute2;

    @TableField("wholesale_price")
    private BigDecimal wholesalePrice;

    @TableField("cost_price")
    private BigDecimal costPrice;

    @TableField("built_in_number")
    private Integer builtInNumber;

    @TableField("itf")
    private String itf;

    public Double getThreeDaysWeight() {
        if (threeDaysWeight == null) {
            return 0.5d;
        }
        return threeDaysWeight;
    }

    public Double getSevenDaysWeight() {
        if (sevenDaysWeight == null) {
            return 0.3d;
        }
        return sevenDaysWeight;
    }

    public Double getThirtyDaysWeight() {
        if (thirtyDaysWeight == null) {
            return 0.2d;
        }
        return thirtyDaysWeight;
    }

    @Override
    protected Serializable pkVal() {
        return this.id;
    }

}
